#ifndef C_GENERATE_BASIC_H__
#define C_GENERATE_BASIC_H__

char* c$generateCharacterLiteral(struct CharacterLiteral* c)
{
	char* r = malloc(5);
	// TODO Handle escaped characters.
	sprintf(r,"'%c'",c->character);
	return r;
}

char* c$generateIntegerLiteral(struct IntegerLiteral* i)
{
	char* r = malloc(12);
	sprintf(r,"%i",i->integer);
	return r;
}

char* c$generateName(struct Name* n) { return n->characters; }

char* c$generateNameList(struct NameList* n)
{
	if(n == NULL) return NULL;

	char* head = c$generateName(n->head);
	char* tail = c$generateNameList(n->tail);

	assert(head != NULL);
	if(tail == NULL) return head;

	char* r = malloc(strlen(head) + strlen(tail) + 2);
	sprintf(r,"%s,%s",head,tail);
	return r;
}

char* c$generateStringLiteral(struct StringLiteral* s)
{
	char* r = malloc(strlen(s->characters) + 3);
	// TODO Handle escape characters.
	sprintf(r,"\"%s\"",s->characters);
	return r;
}

#endif
